const FileManagerPlugin = require('filemanager-webpack-plugin');
const moment = require('moment');
//插件集合
const pluginArr = [
	//打包自动生成zip
	new FileManagerPlugin({
		onStart: {
			delete: ['dist_prod_*.zip'],
		},
		onEnd: {
			archive: [
				{
					source: './dist',
					destination: `./dist_prod_${moment().format('YYYYMMDDHHmm')}.zip`,
				},
			],
		},
	}),
];

module.exports = {
	devServer: {
		proxy: {
			'/api': {
				target: 'http://192.168.0.xxx',
				// target: 'http://121.40.198.96:8000',
				changeOrigin: true,
				ws: true,
				pathRewrite: {
					'^/api': '',
				},
			},
		},
	},
	configureWebpack: {
		plugins: process.env.NODE_ENV === 'production' ? pluginArr : [],
	},
};
